package com.ellecity06.cwhiskymall.view.dialog

import android.app.Activity
import android.graphics.Color
import android.view.LayoutInflater
import android.view.View
import androidx.core.text.buildSpannedString
import androidx.core.text.color
import com.ellecity06.common.base.BaseDialog
import com.ellecity06.common.ktx.colorResToColorId
import com.ellecity06.cwhiskymall.R
import com.ellecity06.cwhiskymall.databinding.DialogReceiveConfirmBinding
import com.ellecity06.cwhiskymall.databinding.DialogReceiveResultBinding

/**
 * @author ellecity06
 * @time 2024/10/30 14:16
 * @des
 */
class ReceiveResultDialog(val context: Activity, private val amount: String, private val onReceive: () -> Unit) : BaseDialog<DialogReceiveResultBinding>(context), View.OnClickListener {
    override val widthP: Float
        get() = 0.8F
    override val isCancelable: Boolean
        get() = false
    override val isTouchOutsideDismiss: Boolean
        get() = false
    override fun inflaterViewBinding(): DialogReceiveResultBinding {
        return DialogReceiveResultBinding.inflate(LayoutInflater.from(context))
    }

    override fun initialize() {
        binding.tvContent.text = buildSpannedString {
            color(R.color.main_color.colorResToColorId()) {
                append("$amount")
            }
            append("贡献金")
        }
        binding.tvReceive.setOnClickListener(this)

    }

    override fun onClick(view: View?) {
        when (view?.id) {
            binding.tvReceive.id -> {
                dismiss()
                onReceive.invoke()
            }
        }
    }

}